package com.ruoyi.tel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tel.domain.TelSiteInfo;
import com.ruoyi.tel.service.ITelSiteInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站址信息Controller
 * 
 * @author lanyuyan
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/tel/info")
public class TelSiteInfoController extends BaseController
{
    @Autowired
    private ITelSiteInfoService telSiteInfoService;

    /**
     * 查询站址信息列表
     */
    @PreAuthorize("@ss.hasPermi('tel:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TelSiteInfo telSiteInfo)
    {
        startPage();
        List<TelSiteInfo> list = telSiteInfoService.selectTelSiteInfoList(telSiteInfo);
        return getDataTable(list);
    }

    /**
     * 导出站址信息列表
     */
    @PreAuthorize("@ss.hasPermi('tel:info:export')")
    @Log(title = "站址信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TelSiteInfo telSiteInfo)
    {
        List<TelSiteInfo> list = telSiteInfoService.selectTelSiteInfoList(telSiteInfo);
        ExcelUtil<TelSiteInfo> util = new ExcelUtil<TelSiteInfo>(TelSiteInfo.class);
        util.exportExcel(response, list, "站址信息数据");
    }

    /**
     * 获取站址信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('tel:info:query')")
    @GetMapping(value = "/{siteId}")
    public AjaxResult getInfo(@PathVariable("siteId") Long siteId)
    {
        return success(telSiteInfoService.selectTelSiteInfoBySiteId(siteId));
    }

    /**
     * 新增站址信息
     */
    @PreAuthorize("@ss.hasPermi('tel:info:add')")
    @Log(title = "站址信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TelSiteInfo telSiteInfo)
    {
        return toAjax(telSiteInfoService.insertTelSiteInfo(telSiteInfo));
    }

    /**
     * 修改站址信息
     */
    @PreAuthorize("@ss.hasPermi('tel:info:edit')")
    @Log(title = "站址信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TelSiteInfo telSiteInfo)
    {
        return toAjax(telSiteInfoService.updateTelSiteInfo(telSiteInfo));
    }

    /**
     * 删除站址信息
     */
    @PreAuthorize("@ss.hasPermi('tel:info:remove')")
    @Log(title = "站址信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{siteIds}")
    public AjaxResult remove(@PathVariable Long[] siteIds)
    {
        return toAjax(telSiteInfoService.deleteTelSiteInfoBySiteIds(siteIds));
    }
}
